<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    #dv {
      width: 500px;
      height: 100px;
      background-color: pink;
    }
  </style>
</head>

<body>
  <!-- 
    element.innerText和element.innerHtml的区别
      1.innerText不识别里面的html标签
      2.innerHTML 识别html标签,w3c标准

    可以通过属性来读写，可以获取里面的内容
      innerText不会保留空格和换行
      innerHtml会保留空格和换行
    推荐使用innerHtml
  --> 
  <div id="dv">
    Lorem ipsum dolor sit
  </div>
  <input type="button" value="替换了吧" id="btn">
  <script>
    let getDate = () => {
      let date = new Date();
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let dates = date.getDate();
      let arr = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"];
      let days = date.getDay();
      let times = `今年是${year}年 ${month}月 ${dates}日 ${arr[days]}`;
      console.log(times);
      return times;
    };
    document.getElementById("btn").addEventListener("click", () => {
      document.getElementById("dv").innerHTML = getDate();
    });
  </script>
</body>

</html>